import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { OrganizationsService } from './organizations.service';
import { CreateOrganizationDto } from './dto/create-organization.dto';
import { UpdateOrganizationDto } from './dto/update-organization.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('组织')
@Controller('organizations')
export class OrganizationsController {
  constructor(private readonly organizationsService: OrganizationsService) {}

  @ApiOperation({ summary: '创建组织' })
  @Post('create')
  create(@Body() createOrganizationDto: CreateOrganizationDto) {
    return this.organizationsService.create(createOrganizationDto);
  }

  @ApiOperation({ summary: '查询所有组织' })
  @Get('queryAll')
  findAll() {
    return this.organizationsService.findAll();
  }

  @ApiOperation({ summary: '查询组织' })
  @Get('query/:id')
  findOne(@Param('id') id: string) {
    return this.organizationsService.findOne(+id);
  }

  @ApiOperation({ summary: '编辑组织' })
  @Post('update')
  update(@Body() updateOrganizationDto: UpdateOrganizationDto) {
    return this.organizationsService.update(updateOrganizationDto);
  }

  @ApiOperation({ summary: '删除组织' })
  @Post('delete/:id')
  remove(@Param('id') id: string) {
    return this.organizationsService.remove(+id);
  }
}
